<template>
    <div class="tableCommon-wrapper">
        <a-table
            :columns="columns"
            :dataSource="data"
            :loading="loading"
            @change="handleTableChange"
            :rowKey="rowKey"
            bordered
            :scroll="scroll"
            ellipsis
            :pagination="pagination"
            :row-selection="selection"
            :childrenColumnName="childrenColumnName"
            :customRow="handleClickRow"
            :rowClassName="rowClassName"
            size="middle"
        >
             <template
                slot-scope="text, record, index"
                :slot="slot"
                v-for="slot in Object.keys($scopedSlots)"
            >
                <slot :name="slot" v-bind="{ text, record, index }"></slot>
            </template>
        </a-table>
    </div>
</template>

<script>
export default {
    name: 'standardTable',
    props: {
        columns: {
            type: Array,
            required: true
        },
        data: {
            type: Array,
            required: true
        },
        loading: {
            type: Boolean,
            default: false
        },
        pagination: {
            type: Boolean | Object
        },
        selection: {
            type: Object
        },
        scroll: {
            type: Object,
            default:()=>{ x: 400}
        },
        rowKey: {
            type: String,
            default: 'id'
        },
        childrenColumnName:{
            type:String,
            default:'children'
        },
        handleClickRow:{
            type:Function,
            default:null
        },
        rowClassName:{
            type:Function,
            default:()=>{}
        }
    },
    data() {
        return {};
    },
    methods: {
        handleTableChange(val) {
            this.$emit('changeCurrent', val.current);
        }
    }
};
</script>
<style lang="scss" scoped>
// .tableCommon-wrapper{
//     width:calc(100vw - 326px)
// }
::v-deep .selected-row{
    background: #e6f7ff;
}
</style>
